package com.ea.eadp.nexus.test.pageDefinition.console;

import org.openqa.selenium.*;

public class SecureQuestionPage extends ConsoleBasePage {

    public SecureQuestionPage(WebDriver driver) {
        super(driver, SecureQuestionPage.class, "panel-security-question");
    }

    public void fillSqAnswer(Integer idx, String secAnswer) {
        //WebElement answer = driver.findElement(By.id("securityAnswer" + idx.toString()));
        //this.sendInput(answer, secAnswer);
        String id = "securityAnswer" + idx.toString();
        JavascriptExecutor jse = (JavascriptExecutor) driver;
        jse.executeScript("$(\"#" + id + "\").val(\"" + secAnswer + "\").blur()");
    }

    public void fillAndSkip() {
        fillSqAnswer(1, "security");
        this.sendControllerKey('X');
    }

    public void selectSecurityQuestion(int step) {
        if (step < 0) {
            step = -step;
        }
        for (int i = 0; i < step; i++) {
            this.sendControllerKey(step > 0 ? Keys.DOWN : Keys.UP);
        }
        this.sendControllerKey('A');
    }
}
